package com.ft.admix.gdt.adapter;

import android.view.View;
import android.view.ViewGroup;

import com.bytedance.sdk.openadsdk.TTAppDownloadListener;
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
import com.ft.admix.ad.MixCustomNativeAd;

public class CustomExpressNativeAd extends MixCustomNativeAd {
    TTNativeExpressAd expressAd;
    private int biddingType;

    public CustomExpressNativeAd(TTNativeExpressAd expressAd, int biddingType) {
        this.expressAd = expressAd;
        this.biddingType = biddingType;
        expressAd.setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() {
            @Override
            public void onAdClicked(View view, int i) {
                callAdClick();
            }

            @Override
            public void onAdShow(View view, int i) {
                callAdShow();
            }

            @Override
            public void onRenderFail(View view, String s, int i) {
                callRenderFail(view, i, s);
            }

            @Override
            public void onRenderSuccess(View view, float v, float v1) {
                callRenderSuccess(v, v1);
            }
        });
        expressAd.setDownloadListener(new TTAppDownloadListener() {
            @Override
            public void onIdle() {
                callOnIdle();
            }

            @Override
            public void onDownloadActive(long l, long l1, String s, String s1) {
                callOnDownloadActive(l, l1);
            }

            @Override
            public void onDownloadPaused(long l, long l1, String s, String s1) {
                callOnDownloadPaused(l, l1, s, s1);
            }

            @Override
            public void onDownloadFailed(long l, long l1, String s, String s1) {
                callOnDownloadFailed(l, l1, s, s1);
            }

            @Override
            public void onDownloadFinished(long l, String s, String s1) {
                callOnDownloadFinished(l, s, s1);
            }

            @Override
            public void onInstalled(String s, String s1) {
                callOnInstalled(s, s1);
            }
        });
        expressAd.setVideoAdListener(new TTNativeExpressAd.ExpressVideoAdListener() {
            @Override
            public void onVideoLoad() {

            }

            @Override
            public void onVideoError(int i, int i1) {
                callVideoError(i, "");
            }

            @Override
            public void onVideoAdStartPlay() {
                callVideoStart();
            }

            @Override
            public void onVideoAdPaused() {
                callVideoPause();
            }

            @Override
            public void onVideoAdContinuePlay() {
                callVideoResume();
            }

            @Override
            public void onProgressUpdate(long l, long l1) {
                callVideoProgressUpdate(l, l1);
            }

            @Override
            public void onVideoAdComplete() {
                callVideoCompleted();
            }

            @Override
            public void onClickRetry() {
            }
        });
        setAdImageMode(expressAd.getImageMode());

    }

    @Override
    public void render(ViewGroup viewGroup) {
        super.render(viewGroup);
        expressAd.render();
    }

    @Override
    public View getExpressView(ViewGroup viewGroup) {
        return expressAd.getExpressAdView();
    }
}
